package rp.lee.musicplayer;

import android.graphics.Color;
import android.view.View;

import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdView;
import com.google.ads.AdRequest.ErrorCode;

public class AdViewListener implements AdListener {
	
	AdView mAdView;
	View mPanel;
	Ad mAd = null;
	public AdViewListener(AdView mAdView, View mPanel) {
		this.mAdView = mAdView;
		this.mPanel = mPanel;
	}
	@Override
	public void onDismissScreen(Ad arg0) {
	}

	@Override
	public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
		if(mAd == null) {
			this.mPanel.setBackgroundResource(R.drawable.banner);
			this.mAdView.setVisibility(View.GONE);
		}
	}

	@Override
	public void onLeaveApplication(Ad arg0) {
	}

	@Override
	public void onPresentScreen(Ad arg0) {
		
	}

	@Override
	public void onReceiveAd(Ad ad) {
		mAd = ad;
		this.mPanel.setBackgroundColor(Color.TRANSPARENT);
		this.mAdView.setVisibility(View.VISIBLE);
	}
}